package com.bang.itstack.day08;

import java.util.ArrayList;

/**
 * @ClassName: Bags
 * @Desc: TODO
 * @author: <Bang>
 * @Date: 2021/10/22 12:04
 * @Version: 1.0
 * @Modified By:
 */
public class Bags implements Articles {

    private String name;     //名字

    private ArrayList<Articles> bags = new ArrayList<Articles>();

    public Bags(String name) {
        this.name = name;
    }

    public void add(Articles c) {
        bags.add(c);
    }
    public void remove(Articles c) {
        bags.remove(c);
    }
    public Articles getChild(int i) {
        return bags.get(i);
    }


    @Override
    public float calculation() {
        float res = 0;
        for (Articles bag : bags) {
            res += bag.calculation();
        }
        return res;
    }

    @Override
    public void show() {
        for (Articles bag : bags) {
            bag.show();
        }
    }
}
